<?php

include "init.php";
if ($_POST["name"] !== '') {
  $type=filter_input(INPUT_POST,'name');
  $sql = "INSERT INTO `reward_pool` (`rp_id`, `rp_name`, `rp_create_datetime`, `rp_used_datetime`) VALUES (NULL, '" . $_POST["name"] . "', CURRENT_TIMESTAMP, NULL)";
  $result = mysqli_query($db_conn, $sql);
  $row = mysqli_affected_rows($db_conn);
  if ((int) $row === 1) {
    echo '新增成功';
  } else {
    echo '新增失敗';
  }
} else {
  echo '獎品名稱不能為空';
}
mysqli_close($db_conn);

